<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2020/2/17
  Time: 23:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<c:set var="ctx" value="<%=basePath%>"  />
<html>
<head>
    <meta charset="UTF-8">
    <title>所有用户</title>
    <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2.0&ak=z6WB81KeyMnLditv8QBmBbo2xEMIKoFi&services=&t=20200103103842"></script>
    <script type="text/javascript" src="//api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
    <link rel="stylesheet" href="//api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
    <script src="/static/js/bookHotel/hotellist/hotellist.js"></script>
    <style type="text/css">
        span{
            color:#008000;
            font-weight: 900;
        }
        #main{
            width: 150px;
            height:150px;
        }
        .col-md-12{
            border-bottom:1px dashed #E0E0E0;
            padding-bottom: 5px;
        }
        .panel{/*面板*/
            box-shadow:0px 0px 0px  0px; /*属性向框添加一个或多个阴影。*/
        }
        /*只显示纵向滑动条*/
        html { overflow-x: hidden; overflow-y: auto }
        /*百度地图样式*/
        .BMapLib_SearchInfoWindow .iw_bt{
            width: auto;
        }
        #BMapLib_stationText1{
            width:40px;
        }
    </style>
    <script>
        var ctx='${ctx}'
    </script>
</head>
<body>
<div class="row">
    <div class="panel <%--panel-default"--%> ">    <%--面板--%>
        <div class="panel-body form-group" style="margin-bottom:0px; padding: 0px 50px 0px 50px;">
            <div class="col-md-12">
                <label class="col-md-1 control-label" style="text-align: right; margin-top:5px;color: #d9534f">酒店城市：</label>
                <div class="col-md-1">
                    <input type="radio"  name="hotelCity" id="search_city"  value=""/>全部
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="hotelCity" id="search_city1"  value="武汉"/>武汉
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="hotelCity" id="search_city2"  value="北京"/>北京
                </div>
            </div>
            <div class="col-md-12">
                <label class="col-md-1 control-label" style="text-align: right; margin-top:5px;color: #d9534f">酒店品牌：</label>
                <div class="col-md-1">
                    <input type="radio"  name="hotelBrand" id="search_hotelBrandType"  value=""/>全部
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="hotelBrand" id="search_hotelBrandType1"  value="1"/>阿娇
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="hotelBrand" id="search_hotelBrandType2" value="2"/>言芳
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="hotelBrand" id="search_hotelBrandTyep3"  value="3"/>玉兰
                </div>
            </div>

            <div class="col-md-12">
                <label class="col-md-1 control-label" style="text-align: right; margin-top:5px;color: #d9534f">酒店类型：</label>
                <div class="col-md-1">
                    <input  type="radio" name="hotelType" value="" id="all" /> 全部
                </div>
                <div class="col-md-1">
                    <input  type="radio" name="hotelType" value="1" id="jj" /> 经济型
                </div>
                <div class="col-md-1">
                    <input  type="radio" name="hotelType" value="2" id="gy"/> 公寓型
                </div>
                <div class="col-md-1">
                    <input  type="radio" name="hotelType" value="3" id="sw"/> 商务型
                </div>
                <div class="col-md-1">
                    <input  type="radio" name="hotelType" value="4" id="ql"/> 情侣酒店
                </div>
            </div>

            <div class="col-md-12">
                <label class="col-md-1 control-label" style="text-align: right; margin-top:5px;color: #d9534f">最低价格：</label>
                <div class="col-md-1">
                    <input type="radio"  name="PriceName" id="search_hotelPrice" value=""/>全部
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="PriceName" id="search_hotelPrice1" value="1"/>低于200
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="PriceName" id="search_hotelPrice2" value="2"/>200-599
                </div>
                <div class="col-md-1">
                    <input type="radio"  name="PriceName" id="search_hotelPrice3" value="3"/>高于600
                </div>
                <div class="col-md-1">
                    <button class="btn btn-primary" id="search_btn">筛选</button>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-8" id="left" style="padding-left: 40px">
        <table  id="mytable"
               class="table table-striped table-hover table-condensed table-bordered">
            <%--<thead>
            <tr>
                <th>酒店名字:</th>
                <th>最低地址:</th>
                <th>酒店地址:</th>
                <th>reviews</th>
                <th>minPrice</th>
            </tr>
            </thead>--%>
            <tbody>
            <c:forEach items="${pageInfo.list}" var="hotelInfo" varStatus="status">
                    <tr class="infoPic${status.index}">
                       <%-- <input type="hidden" id="id${status.index}" value="${hotelInfo.id}">--%>
                        <input type="hidden" id="longitude${status.index}" value="${hotelInfo.longitude}" >
                        <input type="hidden" id="latitude${status.index}" value="${hotelInfo.latitude}">
                        <input type="hidden" id="hotelAddress${status.index}" value="${hotelInfo.hotelAddress}">
                        <td style="width: 160px" rowspan="2">
                            <img id="main" src="/img/picImg?url=${hotelInfo.mainPicLocation}"/>
                        </td>
                        <td><img src="/static/img/hotellist/name1.png" />${hotelInfo.hotelName}</td>
                        <td><img src="/static/img/hotellist/price1.png" />${hotelInfo.hotelMinPrice}</td>
                        <td colspan="2" rowspan="2">
                            <div class="btn-group">
                                <button type="button" class="btn btn-sm btn-danger" onclick="scanInfo('${hotelInfo.id}')">查看详情</button>
                            </div>
                        </td>
                    </tr>

                    <tr class="infoPic${status.index}">
                        <td ><img src="/static/img/hotellist/address1.png" />${hotelInfo.hotelAddress}</td>
                        <td><img src="/static/img/reviews.png" />${hotelInfo.hotelPhone}</td>
                    </tr>

            </c:forEach>
            </tbody>
        </table>
        <p>
            当前 <span>${pageInfo.pageNum}</span> 页,总 <span>${pageInfo.pages}</span> 页,共 <span>${pageInfo.total}</span> 条记录
        </p>
        <ul class="pagination">
            <li><a href="${ctx}hotellist/listpage">第一页</a> </li>
            <c:choose>
                <c:when test="${pageInfo.hasPreviousPage == 'true'}">
                    <li><a href="${ctx}hotellist/listpage?pageNum=${pageInfo.prePage}")>上一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}hotellist/listpage?pageNum=1">上一页</a></li>
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${pageInfo.hasNextPage == 'true'}">
                    <li><a href="${ctx}hotellist/listpage?pageNum=${pageInfo.nextPage}">下一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}hotellist/listpage?pageNum=${pageInfo.pages}">下一页</a></li>
                </c:otherwise>
            </c:choose>
            <li><a href="${ctx}hotellist/listpage?pageNum=${pageInfo.pages}">最后一页</a></li>
        </ul>
    </div>
    <div class="col-md-4">
        <div id="allmap" style="height: 500px;width: 500px">
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    var longitude;
    var latitude;
    var hotelAddress;
    var row;   //行数
    var newRow;
/*    var id;    //酒店id
    var btn;   //查看详情*/
    var marker;  //一个maker

 /*   $('table').find('tr').mouseover(function() {
        var cont = $(this).text(); // 获取到内容
        console.info("桃子大水比:"+cont);
    });*/

   /* $("table tr").hover(function(){
        var lh = $(this).index()+1;//这个前面得到的是tr的序号，从0开始，要得到第几行，+1即可
        console.info(lh)
    })*/
    //鼠标悬停事件
    $("table tr").hover(function () {
         row = $(this).index()  //这个前面得到的是tr的序号，从0开始，要得到第几行，+1即可
         newRow=Math.floor(row/2);   //向下取整
         /*
         var long="longitude"+newRow;
         var lati="latitude"+newRow;
         console.info("调用第x个:"+long+"-"+lati);
        */
        longitude=$("#longitude"+newRow).val();
        latitude=$("#latitude"+newRow).val();
        hotelAddress=$("#hotelAddress"+newRow).val();
        console.info("经度+纬度+btn+id:"+longitude+"-"+latitude+"-"+hotelAddress+"-"+row);
        theLocation();
       /* id=$("#id"+newRow).val();
          btn ="btn"+newRow;*/
  /*      //点击事件
        $("#btn"+newRow).click(function () {
            /!*window.location.href="listDetails&id="+id*!/
            window.location.href="listDetails?id="+id
          /!*  window.location.href="listDetails"*!/
            console.info("button:"+btn);
        })*/
    })
    //点击事件
    function scanInfo(id) {
        window.location.href="listDetails?id="+id
    }

    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(114.27282,30.45875),11);  //启用滚轮放大缩小，默认禁用
    map.enableScrollWheelZoom(true);                                          //启用地图惯性拖拽，默认禁用

    //比例尺、工具条
    var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
    var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
    var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL});

    map.addControl(top_left_control);
    map.addControl(top_left_navigation);
    map.addControl(top_right_navigation);


    // 用经纬度设置地图中心点
    function theLocation(){
            var new_point = new BMap.Point(longitude,latitude);
            marker = new BMap.Marker(new_point);  // 创建标注
            map.clearOverlays()                  //去除先前所有的标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(new_point);
            marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画

            marker.addEventListener("click", function(){
                searchInfoWindow.open(marker);
            })

            var content =hotelAddress+"";
            //创建检索信息窗口对象
            var searchInfoWindow = null;
            searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
                title  : "酒店",      //标题
                width  : 300,             //宽度
                height : 0,              //高度
                panel  : "panel",         //检索结果面板
                enableAutoPan : true,     //自动平移
                searchTypes   :[
                    BMAPLIB_TAB_SEARCH,   //周边检索
                    BMAPLIB_TAB_TO_HERE,  //到这里去
                    BMAPLIB_TAB_FROM_HERE //从这里出发
                ]
            });


    }

</script>
</html>

